<template>
     <div><el-dialog title="新增角色" :visible.sync="resw">
		  <el-form :model="relist">
		    <el-form-item label="名称" prop="name" :label-width="formLabelWidth">
		      <el-input v-model="relist.name"  autocomplete="off"></el-input>
		    </el-form-item>
		    <el-form-item label="职位" :label-width="formLabelWidth">
		      <el-input v-model="relist.nameZh" autocomplete="off"></el-input>
		    </el-form-item>
		  </el-form>
		  <div slot="footer" class="dialog-footer">
		    <el-button @click="qxadsw">取 消</el-button>
		    <el-button type="primary" @click="adda">确 定</el-button>
		  </div>
  </el-dialog>
</div>
</template>
<!-- 分界线 -->
<script>
import axios from "axios";
// var zhu = {
// };
export default {
  name: "RoleAdd",
  props: {
    msg: String
  },
  data() {
    return {
         zhu: {
                    relist: {},
                    resw:true,
                    formLabelWidth: '120px',
                    pageList: {}
               },
               rules: {
                name: [
                    { required: true, message: '请输入名称', trigger: 'blur' },
                    { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
                ]
         }
   }
  },
  mounted: function() {
    this.resw = true;
  },
  methods: {
    adda: function() {
       alert("你好，很高兴为您服务！！！");
        console.log(this.relist);
        var k = this;
        k.$ajax({
          mounted: "get",
           url: "http://localhost:8081/role/roleadd",
           params: this.relist
        }).then(function(q){
            if(q){
             alert("，您好，恭喜你新增成功！！！");
             now.$router.replace({path: '/role'});
            }
             alert("，您好，很抱歉你新增失败！！！");
             this.$router.replace({path: '/role'});
        });
    },
    qxadsw: function(){
        this.relist = [];
        this.resw = false;
        alert("你好，你慢走！！！");
       this.$router.replace({path: '/role'});
    }
  }
};
</script>